<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>



    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->

</head>

<body>

<h2>欢迎访问中凯web服务器</h2>
<%--<fieldset>
    <legend>图片上传</legend>
    <h2>只能上传单张10M以下的 PNG、JPG、GIF 格式的图片222</h2>
    <form action="pic/versions" method="post" enctype="multipart/form-data">
        选择文件:<input type="file" name="file">
        <input type="submit" value="上传">
    </form>


    <form id="form_save_stu" class="form form-horizontal" enctype="pic/versions" method="post">
        <div class="form-group">
            <label class="control-label col-sm-3">学号</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="text_s_id" name="sid">
            </div>
        </div>

        <div class="form-group" id="form_group_photo">
            <label class="control-label col-sm-3">相片</label>
            <div class="col-sm-5">
                <input type="file" id="text_file" name="file">
            </div>
        </div>

        <input class="btn btn-warning" type="reset" value="重置"></input>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <input type="button" class="btn btn-primary" id="button_add_ok" value="提交"/>

    </form>

</fieldset>--%>
</body>

<script type="text/javascript">


    $('button_add_ok').click(function () {
        var formData = new FormData();
        formData.append("ver", "1.0.1");
        console.log(document.getElementById("text_file").files[0]);
        formData.append("file", document.getElementById("text_file").files[0]);
        $.ajax({
            type: "POST",
            url: "",
            data: formData,
            contentType: false,
            processData: false,//用于对data参数进行序列化处理 这里必须false
            success: function (data) {
                alert(data);
            }
        });
    })



</script>
</html>

